﻿<%@ Control Language="C#" Inherits="Yuanlin.Business.SpecialNewsEditControl, Yuanlin.Business" AutoEventWireup="true" %>

<%@Register tagPrefix="ctrl" tagName="Editor" src="~/themes/default/skins/Skin-HtmlEditor.ascx" %>

<script language="javascript" type="text/javascript">
<!--
function GetCities()
{
    var parentCategoryID = document.getElementById('<%= provinceDropDownList.ClientID %>').value;
    if(parentCategoryID != null)
    {             
        SpecialNews.GetChildCategories('<%= ClientID %>', parentCategoryID,  GetCitiesCallBack);
    }
}
function GetTowns()
{
    var parentCategoryID = document.getElementById('<%= cityDropDownList.ClientID %>').value;
    if(parentCategoryID != null)
    {             
        SpecialNews.GetChildCategories('<%=ClientID %>', parentCategoryID,  GetTownsCallBack);
    }
}
function GetSmallTowns()
{
    var parentCategoryID = document.getElementById('<%= townDropDownList.ClientID %>').value;
    if(parentCategoryID != null)
    {     
        document.getElementById('<%= townHidden.ClientID %>').value = parentCategoryID;        
        SpecialNews.GetChildCategories('<%=ClientID %>', parentCategoryID,  GetSmallTownsCallBack);
    }
}
function changeSmallTowns()
{
    var parentCategoryID = document.getElementById('<%= smallTownDropDownList.ClientID %>').value;
    if(parentCategoryID != null)
    {  
        document.getElementById('<%= smallTownHidden.ClientID %>').value = parentCategoryID;
    }
}
function GetCitiesCallBack(res)
{
    var ddl = document.getElementById('<%= cityDropDownList.ClientID %>');
    ClearOptions(ddl);
 
    if(res.value == null || res.value == "")
    {
        return;
    }   
    var categories = res.value.split(";");
    for(var i = 0; i < categories.length; i++) { 
        var category = categories[i].split(":");
        var newOption=new Option(category[1],category[0]);
        ddl.options.add(newOption); 
    }  

    if(ddl.length > 0)
    {
        ddl.selectedIndex = 0;
        GetTowns(); 
    }
    
}
function GetTownsCallBack(res)
{
    var ddl = document.getElementById('<%= townDropDownList.ClientID %>');
    ClearOptions(ddl);
 
    if(res.value == null || res.value == "")
    {
        return;
    }   
    var categories = res.value.split(";");
    for(var i = 0; i < categories.length; i++) { 
        var category = categories[i].split(":");
        var newOption=new Option(category[1],category[0]);
        ddl.options.add(newOption); 
    }  

    if(ddl.length > 0)
    {
        ddl.selectedIndex = 0; 
        GetSmallTowns();
    }
}
function GetSmallTownsCallBack(res)
{
    var ddl = document.getElementById('<%= smallTownDropDownList.ClientID %>');
    ClearOptions(ddl);
 
    if(res.value == null || res.value == "")
    {
        return;
    }   
    var categories = res.value.split(";");
    for(var i = 0; i < categories.length; i++) { 
        var category = categories[i].split(":");
        var newOption=new Option(category[1],category[0]);
        ddl.options.add(newOption); 
    }  

    if(ddl.length > 0)
    {
        ddl.selectedIndex = 0; 
        changeSmallTowns();
    }
}
function ClearOptions(list) 
{ 
    while (list.options.length > 0) 
    { 
        list.options[0] = null; 
    } 
}
function checkInfo() {

    var title = document.getElementById('<%= titleValuedTextBox.ClientID %>');
    if(title.value.length==0)
    {
        alert('请填写标题！');
        title.focus();
        return false;
    }

    var provinceDropDownList =  document.getElementById('<%= provinceDropDownList.ClientID %>');
    var cityDropDownList =  document.getElementById('<%= cityDropDownList.ClientID %>');
    var townDropDownList =  document.getElementById('<%= townDropDownList.ClientID %>');
    var smallTownDropDownList =  document.getElementById('<%= smallTownDropDownList.ClientID %>');
    if(provinceDropDownList.selectedIndex == "-1")
    {
        alert('请选择所在地区！');
        provinceDropDownList.focus();
        return false;
    } 
    if(cityDropDownList.selectedIndex == "-1")
    {
        alert('请选择所在地区！');
        cityDropDownList.focus();
        return false;
    }
    if(townDropDownList.selectedIndex == "-1")
    {
        alert('请选择所在地区！');
        cityDropDownList.focus();
        return false;
    }
    if(smallTownDropDownList.selectedIndex == "-1")
    {
        alert('请选择所在地区！');
        cityDropDownList.focus();
        return false;
    }
        
    return true;
}
//-->
</script>
<asp:HiddenField ID="townHidden" runat="server" />
<asp:HiddenField ID="smallTownHidden" runat="server" />
<div class="AdminArea">
    <fieldset>
        <legend><nwap:ResourceLiteral runat="server" ResourceName="System_Applications_Yuanlin_EditHuamuShichangNews" ResourceFile="ControlPanelResources.xml"></nwap:ResourceLiteral></legend>

        <div class="FormRow">
            <div class="LargerFieldNameRequireCharacter">
                <nwap:ResourceLabel ID="ResourceLabel3" runat="Server" CssClass="RedColor" ResourceFile="ControlPanelResources.xml" ResourceName="RequireCharacter" />
                <nwap:ResourceLabel ID="ResourceLabel4" runat="Server" ControlToLabel="titleValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_HuamuHuizhanNews_Title" />
            </div>
            <nwap:ValuedTextBox Runat="server" CssClass="InputField MiddleWidth" id="titleValuedTextBox" />
        </div>
        
        <div class="FormRow">
            <nwap:ResourceLabel ID="ResourceLabel1" CssClass="FieldName" runat="Server" ControlToLabel="categoryDropDownList" ResourceFile="ControlPanelResources.xml" ResourceName="Category" />
            <nwap:ValuedDropDownList Runat="server" CssClass="DropDownList" id="categoryDropDownList" />
        </div>
        
		<div class="FormRow">
            <div class="LargerFieldNameRequireCharacter">
                <nwap:ResourceLabel runat="Server" CssClass="RedColor" ResourceFile="ControlPanelResources.xml" ResourceName="RequireCharacter" />
                <nwap:ResourceLabel runat="Server" ControlToLabel="provinceDropDownList" ResourceFile="ControlPanelResources.xml" ResourceName="EditProfile_UserArea" />
            </div>
            <nwap:ValuedDropDownList Runat="server" CssClass="InputField MicroWidth" onchange="GetCities()" id="provinceDropDownList" Enabled="false"/>
            &nbsp;&nbsp;<nwap:ValuedDropDownList Runat="server" CssClass="InputField MicroWidth" onchange="GetTowns()" id="cityDropDownList" Enabled="false"/>
            &nbsp;&nbsp;<nwap:ValuedDropDownList Runat="server" CssClass="InputField MicroWidth" onchange="GetSmallTowns()" id="townDropDownList" Enabled="false"/>
            &nbsp;&nbsp;<nwap:ValuedDropDownList Runat="server" CssClass="InputField MicroWidth" onchange="changeSmallTowns()" id="smallTownDropDownList" Enabled="false"/>
        </div>

        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="bodyValuedEditor" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_HuamuShichangNews_Body" />
            <br /><br /><ctrl:Editor Runat="server" Width="100%" Height="250px" id="descriptionValuedEditor" />
        </div>


        <div class="FormRow SubmitButtonRow">
            <nwap:Resourcebutton id="SaveButton" ResourceName="Save" CssClass="Button" Runat="server" OnClientClick="return checkInfo();"></nwap:Resourcebutton>&nbsp;&nbsp;&nbsp;&nbsp;
            <nwap:Resourcebutton id="BackButton" ResourceName="Back" CssClass="Button" Runat="server"></nwap:Resourcebutton>
        </div>	
    </fieldset>
</div> 

